perm filename SIG.MAC[SYS,ALS] blob sn#001168 filedate 1972-07-06 generic text, type T, neo UTF8
00010	TITLE SIG
00020	
00030	ENTRY SIG
00040	
00045		;Signature table processing routine.
00050		;Version with line by line computation and spreading for P tables.
00060		;Also contains TABLET section. June 12 1972.
00070	
00080	EXTERNAL TABLES,HINT,UPCNT
00090	EXTERNAL INDAT,INCNT,FLAG
00100	
00110	;    Name   Rel. Loc.	Usage
00120		OUT=0		;Most recent table output in leftmost bits
00130		SIGTYP=1	;3 fields,Table type,No of inputs,Gate sign and level
00140		LEARN=2		;4 PH numbers if Q table or pointer to feature if P
00150		GATE=3		;Gating byte pointer
00160		IN1=4		;Byte pointer to first input
00170		IN2=5		;Byte pointer to second input
00180		IN3=6		;Byte pointer to third input
00190		IN4=7		;Byte pointer to fourth input
00200		IN5=10		;Byte pointer to fifth input
00210		IN6=11		;Byte pointer to sixth input
00220		SIGTAB=12	;Start of actual table
00230	
00240	EXTERNAL	TABLET,SEGC,TFLAG
00250	
00260	;	Name	Rel.Loc	Usage as referenced in section starting with XXX
00270		OUT=	0	;Most recent outputs
00280	 	SIGTYP=	1	;SIXBIT name of tablet
00290		ALDATA=	2	;Unused(1),Level(3),toler(2),excnt(2)
00300				;SFLAG(5),exsum(5),segsum(18)
00310		OUT1=	3	;Next older outputs
00320		IN1=	4	;Byte pointer to input
00330	
00340	;Index register assignments
00350	;Regester	Usage
00360	Z=0		; general purpose register
00370	I=1		;Used to index between tables (incremented by 74)
00380	J=2		;Used to index within  tables
00390	K=3		;Special purpose indexing and general use when Z not wanted
00400	L=4
00410	M=5		;Used to hold counter bit
00420	N=6
00430	P=7		;Used to index INDAT files
00440	Q=10		;Used to hold mask
00450	R=11		;Used to hold quantized marker
00460	S=12
00470	T=13		;Reserved exclusively for the address of the first word in TABLES
00480	F=14
00490	H=15		;Used to hold HINT word repeated in right 3 6-bit fields
00500	PO=16		;NO LONGER USED
00510	X=17		;Used to index in buckets
00520	
00530	SIG:	0
00540		MOVEM	17,SAVE+17
00550		MOVE	17,[XWD 0,SAVE]
00560		BLT	17,SAVE+16
00570	
00580	TIN1:	MOVE	Z,@0(16)
00590		MOVE	T,TABLES	;Necessary for IN pointers to work
00600		MOVE	Z,INDAT
00610		HRRM	Z,TIN2
00620		MOVE	Z,INCNT
00630		HRRM	Z,TIN3		;START OF INCNT
00635		HRRM	Z,.+1
00637		AOS	0		;ADD TO INCNT ONCE ONLY
00640		MOVE	H,HINT
00650		LSH	H,6
00660		ADD	H,HINT
00670		LSH	H,6
00680		ADD	H,HINT
00690		LSH	H,6
00700		ADD	H,HINT
00710		SETZ	P,		;To index input data
00720		MOVEI	M,20		;Counter bit for I table
00730		MOVE	Q,[777777777760]	;Mask
00740		MOVE	I,TABLES	;To index tables
00750	TIN2:	MOVE	J,0(P)		;Get INDAT value into index
00752		CAIGE	J,0		;Limit minimum to 0
00754		MOVEI	J,0
00756		CAILE	J,77		;Limit maximum to 63
00758		MOVEI	J,77
00760		ADD	J,I
00770		MOVE	K,SIGTAB(J)	
00780		ADDM	M,SIGTAB(J)
00790		MOVE	L,OUT(I)
00800		LSHC	K,-3		;Shift out oldest and add newest output
00810		MOVEM	L,OUT(I)	
00820	TIN3:	MOVE	N,0		;Get count from INCNT to determine bucket size
00845		CAILE	N,20000		;Stop updating at this number
00857		JRST	TIN6
00870	TIN3A:	TRNE	N,7		;Is it time to update
00880		JRST	TIN6		;No
00890		LSH	N,-3		;Divide by 8 to get number for each bucket
00900	TIN3B:	LSH	N,4		;To line up with count field
00910		MOVEI	K,77		;Use to count entries
00920		MOVE	J,I
00930		SETZ	R,		;Quantized output marker starts at 0
00940		SETZ	Z,		;To accumulate total number of references
00950	TIN4:	ANDM	Q,SIGTAB(J)	;Save count only and zero output field
00960		ADD	Z,SIGTAB(J)	;Count in current bucket
00970		ORM	R,SIGTAB(J)	;Add output field
00980		CAMGE	Z,N		;Is it time to change output marker
00990		JRST	TIN5		;No
01000		CAIGE	R,7		;Guard against too large value
01010		ADDI	R,1		;Can change safely
01020		SUB	Z,N		;Keep overshoot
01030	TIN5:	AOS	J
01040		SOJGE	K,TIN4
01050	TIN6:	ADDI	I,112		;To go to the next table
01060		AOS	P		;Keep INDAT index in step
01070		SKIPN	SIGTYP(I)	;Test table type
01080		JRST	TIN2		;Still more input tables
01090		MOVEM	I,ISAV#		;Save start of P-Q region in prep for update
01100	PQ1:	SKIPN	SIGTYP(I)	;A 0 value NOW means end of tables
01110		JRST	XXX		;Go to tablets
01120		LDB	K,GATE(I)	;Is this table to be used
01130		LDB	L,GPOINT	;Get gating threshold
01140		SUB	K,L		;Is level high enough
01141	
01142		CAIGE	L,10		;Test for negative gate
01143		JRST	.+4
01144		ADDI	K,10
01145		JUMPLE	K,PQ2
01146		SKIPA
01147	
01150		JUMPGE	K,PQ2		; Yes
01160		LDB	L,TPOINT	; Find table type
01170		JUMPN	L,PQ1A		;Must be a Q table
01180		MOVE	L,OUT(I)	;Fix table output for gate off case
01190		LSH	L,-3		;Introuce a 0
01200		MOVEM	L,OUT(I)	;Output and go to next table
01210		JRST	PP2
01220	
01230	PQ1A:	MOVE	K,OUT(I)
01240		MOVE	L,OUT+112(I)
01250		LSHC	K,-22
01260		MOVEM	L,OUT+112(I)
01270		MOVE	L,OUT(I)
01280		LSH	L,-22		;Shift 18 places for Q table
01290		OR	L,[700000000000]	;Add the NOT-ANY output for Q table
01300		MOVEM	L,OUT(I)
01310		JRST	PQ8		;Go to next table
01320	
01330	PQ2:	LDB	J,IN1(I)	;J used to accumulate index to line
01340		LDB	K,IN2(I)
01350		LDB	L,NPOINT	;To get number of inputs from SIGDAT
01360		CAILE	L,3		;Is it a 2- or a 3-input type
01370		JRST	PQ6		;NO, it is a 6-input table
01380		CAILE	L,2		;Is it a 2 input table
01390		JRST	PQ3		;No, it has 3 inputs
01400		DPB	K,D2N2		;Deposit as 2nd of 2 inputs
01410		JRST	PQX
01420	
01430	PQ3:	DPB	K,D2N3		;Deposit as 2nd of 3 inputs
01440		LDB	K,IN3(I)
01450		DPB	K,D3N3		;Deposit as 3rd of 3
01460		JRST	PQX
01470	
01480	PQ6:	DPB	K,D2N6		;Deposit as 2nd of 6
01490		LDB	K,IN3(I)
01500		DPB	K,D3N6		;3 of 6
01510		LDB	K,IN4(I)
01520		DPB	K,D4N6		;4 of 6
01530		LDB	K,IN5(I)
01540		DPB	K,D5N6		;5 of 6
01550		LDB	K,IN6(I)
01560		DPB	K,D6N6		;6 of 6
01570	PQX:	ADD	J,I		;Add start of table I address to J
01580		LDB	K,TPOINT	;Now find whether P or Q table
01590		JUMPN	K,QQ1		;A 1 in this field means Q
01600		MOVE	K,SIGTAB(J)	;Get new output
01610		MOVE	L,OUT(I)
01620		LSHC	K,-3		;Displace oldest and add newest to left
01630		MOVEM	L,OUT(I)
01640		JUMPE	H,PP2		;A 0 in H means no learning
01650		LDB	L,LEARN(I)	;Gets proper bit from PONY word
01660		MOVSI	K,4		;Adds to not-on count
01670		SKIPE	L		;Means sig.feature not indicated
01680		MOVEI	K,20		;Adds to on count
01690		ADDM	K,SIGTAB(J)	;Add learning
01700		LDB	K,GDPNT
01710		LDB	Z,BADPNT
01720		ADD	Z,K
01730		LSH	K,4		;Multiply by 16
01740		IDIV	K,Z
01750		MOVE	Z,SPREAD(K)	;Convert to range 0 to 7
01760		DPB	Z,OTXPT		;Updated output for this entry
01770	PP2:	ADDI	I,112
01780		JRST	PQ1
01790	
01800	QQ1:	MOVE	K,OUT(I)
01810		MOVE	L,OUT+112(I)
01820		LSHC	K,-22
01830		MOVEM	L,OUT+112(I)
01840		MOVE	K,SIGTAB(J)	;Get new output
01850		MOVE	L,OUT(I)
01860		LSHC	K,-22		;18-bit fields in output for Q tables
01870		MOVEM	L,OUT(I)
01880		JUMPE	H,PQ8		;0 means no learning
01890		MOVE	Z,H
01900		XOR	Z,LEARN(I)	;Test appropiate phonemes
01910		MOVEI	K,1		;Learning add-bit if phoneme 4
01920		TRNN	Z,77		;Test last field
01930		JRST	QQ2
01940		LSH	K,11
01950		TRNN	Z,7700		;Test next field
01960		JRST	QQ2
01970		LSH	K,11
01980		TRNN	Z,770000	;Test next field
01990		JRST	QQ2
02000		LSH	K,11
02010		TLNN	Z,77
02020		JRST	QQ2
02030		MOVSI	K,1
02040		ADDM	K,SIGTAB(J)
02050		SKIPA
02060	QQ2:	ADDM	K,SIGTAB+112(J)	;Add learning count
02070		LDB	K,UPDPT		;Get update count
02080		ADDI	K,1
02090		DPB	K,UPDPT		;Automatically modulo 4
02100		CAIE	K,2		;Is it time to update this line
02110		JRST	PQ8		;No, lines updated at 2 mod 4
02120		LDB	Z,NOTPT
02130		LDB	K,PH1PT
02140		ADD	Z,K
02150		LDB	K,PH2PT
02160		ADD	Z,K
02170		LDB	K,PH3PT
02180		ADD	Z,K
02190		LDB	K,PH4PT
02200		ADD	Z,K		;Total count for line
02210		LSH	K,4		;Multiply by 16 to start
02220		IDIV	K,Z
02230		ADDI	K,1		;To round
02240		LSH	K,-1		;Now reduce range
02250		CAILE	K,7
02260		MOVEI	K,7		;Limit maximum to 7
02270		DPB	K,OT4PT
02280		MOVE	L,K
02290		MOVEI	R,4
02300		LDB	K,PH3PT		;Repeat for each component
02310		LSH	K,4
02320		IDIV	K,Z
02330		ADDI	K,1
02340		LSH	K,-1
02350		CAILE	K,7
02360		MOVEI	K,7
02370		DPB	K,OT3PT
02380		CAMG	K,L
02390		JRST	.+3
02400		MOVE	L,K
02410		MOVEI	R,3
02420		LDB	K,PH2PT	
02430		LSH	K,4
02440		IDIV	K,Z
02450		ADDI	K,1
02460		LSH	K,-1
02470		CAILE	K,7
02480		MOVEI	K,7
02490		DPB	K,OT2PT
02500		CAMG	K,L
02510		JRST	.+3
02520		MOVE	L,K
02530		MOVEI	R,2
02540		LDB	K,PH1PT
02550		LSH	K,4
02560		IDIV	K,Z
02570		ADDI	K,1
02580		LSH	K,-1
02590		CAILE	K,7
02600		MOVEI	K,7
02610		DPB	K,OT1PT
02620		CAMG	K,L
02630		JRST	.+3
02640		MOVE	L,K
02650		MOVEI	R,1
02660		LDB	K,NOTPT
02670		LSH	K,4
02680		IDIV	K,Z
02690		ADDI	K,1
02700		LSH	K,-1
02710		CAILE	K,7
02720		MOVEI	K,7
02730		DPB	K,NTOPT
02740		CAML	K,L		;Call it a not-any if equal
02750		SETZ	R,
02760		DPB	R,OTXPT
02770	PQ8:	ADDI	I,224		;Double space for Q table
02780		JRST	PQ1		;Go to next table
02790	
02800	XXX:	MOVE	F,TABLET	;For pointers to words in tablet
02810		MOVEI	R,0		;For zeroing ex values as needed
02820	XXX2:	LDB	L,LEVPT		;Get level
02830		JUMPE	L,FINISH	;0 level reserved for end of table
02840		LDB	K,IN1(F)
02850		LDB	Z,PAVER		;Used to see if in + state
02860		JUMPE	Z,PXX		;We are since OUT has been shifted
02870	MXX:	CAMGE	K,L		;Is input below threshold
02880		JRST	RET		;Yes so we are still marking time
02890	MPX:	LDB	X,EXSUM		;May be starting a + state so save data
02900		ADD	X,K
02910		DPB	X,EXSUM		;Save now
02920		LDB	J,EXCNT		;Update exception count
02930		ADDI	J,1
02940		DPB	J,EXCNT
02950		LDB	Q,TOLPT		;Now compare with tolerance count
02960		CAMG	J,Q
02970		JRST	RET		;Not enough exceptions to start + state
02980		MOVE	J,OUT(F)	;We are entering + state
02990		MOVE	K,OUT1(F)
03000		LSHC	J,-22		;Make room for new data
03010		MOVEM	J,OUT(F)
03020		MOVEM	K,OUT1(F)
03030		DPB	X,SEGSUM	;Transfer exsum to segsum
03040		DPB	R,EXSUM		;Zero EXSUM
03050		DPB	R,EXCNT		;Also reset excnt
03060		MOVE	Z,SEGC		;Save correct segc
03070		SUB	Z,Q		;Correct for delayed decision
03080		DPB	Z,PPNTA		;Put it into OUT(F)
03090		JRST	RET		;Go to next tablet
03100	
03110	PXX:	CAML	K,L		;We must now test level
03120		JRST	PPX		;Continuation of + state
03130		LDB	X,EXSUM		;May be ending + state but also may not
03140		ADD	X,K		;Save temporarily
03150		DPB	X,EXSUM
03160		LDB	J,EXCNT		;Check on length of exception period
03170		ADDI	J,1
03180		DPB	J,EXCNT
03190		LDB	Q,TOLPT		;Has it reached tolerance limit
03200		CAMG	J,Q
03210		JRST	RET		;No
03220		MOVE	Z,SEGC		;Find end segc
03230		LDB	L,PPNTA
03240		SUB	Z,L
03250		SUB	Z,Q
03260		DPB	Z,PCNT		;Save duration count
03270		LDB	J,SEGSUM
03280		LSH	J,1		;Prepare to round
03290		IDIV	J,Z		;Get average value
03300		ADDI	J,1
03310		LSH	J,-1		;Rounding complete
03320		DPB	J,PAVER		;Save
03330		DPB	R,SEGSUM	;Reset to zero
03340		DPB	R,EXCNT
03350		DPB	R,EXSUM
03360		LDB	Z,SFLAG
03370		ADDI	Z,1
03380		DPB	Z,SFLAG		;Count of states since reset
03390		AOS	TFLAG		;Add to count of total state changes
03400		JRST	RET
03410	
03420	PPX:	ADDM	K,ALDATA(F)	;Continuation of normal + state
03430		LDB	J,EXCNT		;Have any exceptions occured
03440		JUMPLE	J,RET		;If not we are through
03450		LDB	X,EXSUM		;Must transfer to segsum
03460		ADDM	X,ALDATA(F)	;Right half is segsum remember
03470		DPB	R,EXCNT
03480		DPB	R,EXSUM		;Reset ex values
03490	RET:	ADDI	F,5
03500		JRST	XXX2		;Go to next TABLET
03510	
03520	PAVER:	POINT	3,OUT(F),2	;Average input during state
03530	PPNTA:	POINT	8,OUT(F),10	;SEGC at start of state
03540	PCNT:	POINT	7,OUT(F),17	;count of segments during state
03550	
03560	LEVPT:	POINT	3,ALDATA(F),3	;Pre-assigned level
03570	TOLPT:	POINT	2,ALDATA(F),5	;Exception tolerance value
03580	EXCNT:	POINT	2,ALDATA(F),7	;Count of exceptions
03590	SFLAG:	POINT	5,ALDATA(F),12	;Count of state changes for this TAABLET
03600	EXSUM:	POINT	5,ALDATA(F),17	;Running sum during exception periods
03610	SEGSUM:	POINT	18,ALDATA(F),35	;Running sum during + state
03620	
03630	FINISH:	MOVE	17,[XWD SAVE,0]
03640		BLT	17,17
03650		JRA	16,1(16)
03660	
03670	
03680	SAVE:	BLOCK	20
03690	SUM:	Z
03700	
03710	UPDPT:	POINT	2,SIGTAB(J),1	;Space for update record mod 4
03720	NOTPT:	POINT	16,SIGTAB(J),17
03730	PH1PT:	POINT	9,SIGTAB+112(J),8
03740	PH2PT:	POINT	9,SIGTAB+112(J),17
03750	PH3PT:	POINT	9,SIGTAB+112(J),26
03760	PH4PT:	POINT	9,SIGTAB+112(J),35
03770	
03780	OTXPT:	POINT	3,SIGTAB(J),35
03790	NTOPT:	POINT	3,SIGTAB(J),20
03800	OT1PT:	POINT	3,SIGTAB(J),23
03810	OT2PT:	POINT	3,SIGTAB(J),26
03820	OT3PT:	POINT	3,SIGTAB(J),29
03830	OT4PT:	POINT	3,SIGTAB(J),32
03840	
03850	D2N2:	POINT	3,J,32		;For depositing second input to A 2-input table
03860	D2N3:	POINT	2,J,33		;For depositing 2ND input to A 3 INPUT TABLE
03870	D3N3:	POINT	2,J,31
03880	D2N6:	POINT	1,J,34
03890	D3N6:	POINT	1,J,33
03900	D4N6:	POINT	1,J,32
03910	D5N6:	POINT	1,J,31
03920	D6N6:	POINT	1,J,30
03930	
03940	BPT3:	POINT	3,L,2		;For first 3 bits of L
03950	BPT12:	POINT	12,L,11		;For first 12 bits of L
03960	GPOINT:	POINT	4,SIGTYP(I),17	;For gating threshold from SIGTYP
03970	TPOINT:	POINT	1,SIGTYP(I),5	;For Q indicator bit in SIGTYP
03980	NPOINT:	POINT	3,SIGTYP(I),11	;For number of inputs
03990	GDPNT:	POINT	16,SIGTAB(J),31	;GOOD field for P type tables
04000	BADPNT:	POINT	16,SIGTAB(J),15	;BAD field for P type tables
04010	SPREAD:	OCT	0,0,1,1		;Can be used to spread outputs
04020		OCT	2,2,3,3
04030		OCT	4,4,5,5
04040		OCT	6,6,7,7,7
04050	
04060	
04070		END